%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/exclusively-archived-messages"
    Bucket0("Bucket 0 (root)<br /><br />1: 76, 80<br />ᐳ: 9, 10, 93, 95, 96, 11, 13, 29<br />2: 84, 88<br />3: PgSelect[8]<br />ᐳ: Access[85], Access[89]<br />4: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 93, 85, 89<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 93, 85, 15, 89<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 86, 90, 87, 91<br />2: Connection[25]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25, 91, 87<br /><br />ROOT Connection{2}ᐸ87ᐳ[25]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 47, 77, 81<br /><br />ROOT __Item{6}ᐸ30ᐳ[41]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 42, 77<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[42]<br />1: <br />ᐳ: 51, 78, 79<br />2: PgSelectRows[60]<br />ᐳ: First[59], PgSelectSingle[61]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 43, 42, 81, 53<br /><br />ROOT Edge{6}[43]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 61<br /><br />ROOT PgSelectSingle{7}ᐸusersᐳ[61]"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 42, 81<br /><br />ROOT PgSelectSingle{6}ᐸmessagesᐳ[42]<br />1: <br />ᐳ: 64, 82, 83<br />2: PgSelectRows[72]<br />ᐳ: First[71], PgSelectSingle[73]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 73<br /><br />ROOT PgSelectSingle{10}ᐸusersᐳ[73]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket6
    Bucket6 --> Bucket7 & Bucket8
    Bucket7 --> Bucket9
    Bucket8 --> Bucket10
    Bucket10 --> Bucket11

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'YES' ]ᐳ[95]"}}:::plan
    PgSelectInlineApply84["PgSelectInlineApply[84∈0] ➊<br />More deps:<br />- Constantᐸ5ᐳ[93]"]:::plan
    PgSelectInlineApply88["PgSelectInlineApply[88∈0] ➊"]:::plan
    Object11 & Lambda13 & PgSelectInlineApply84 & PgSelectInlineApply88 --> PgSelect8
    Lambda29{{"Lambda[29∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[96]"}}:::plan
    PgSelectInlineApply76["PgSelectInlineApply[76∈0] ➊"]:::plan
    PgSelectInlineApply80["PgSelectInlineApply[80∈0] ➊"]:::plan
    Lambda29 & PgSelectInlineApply76 & PgSelectInlineApply80 --> PgSelectInlineApply84
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    Access85{{"Access[85∈0] ➊<br />ᐸ8.m.subqueryDetailsFor21ᐳ"}}:::plan
    PgSelect8 --> Access85
    Lambda29 --> PgSelectInlineApply88
    Access89{{"Access[89∈0] ➊<br />ᐸ8.m.subqueryDetailsFor36ᐳ"}}:::plan
    PgSelect8 --> Access89
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    Connection25[["Connection[25∈2]<br />ᐸ87ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[93]"]]:::plan
    Lambda87{{"Lambda[87∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda87 --> Connection25
    List86{{"List[86∈2]<br />ᐸ85,15ᐳ"}}:::plan
    Access85 & __Item15 --> List86
    List90{{"List[90∈2]<br />ᐸ89,15ᐳ"}}:::plan
    Access89 & __Item15 --> List90
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    List86 --> Lambda87
    Lambda91{{"Lambda[91∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List90 --> Lambda91
    PgCursor48{{"PgCursor[48∈3]"}}:::plan
    First46{{"First[46∈3]"}}:::plan
    Access47{{"Access[47∈3]<br />ᐸ87.cursorDetailsᐳ"}}:::plan
    First46 & Access47 --> PgCursor48
    PgCursor50{{"PgCursor[50∈3]"}}:::plan
    Last49{{"Last[49∈3]"}}:::plan
    Last49 & Access47 --> PgCursor50
    ConnectionItems30[["ConnectionItems[30∈3]"]]:::plan
    Connection25 --> ConnectionItems30
    PageInfo35{{"PageInfo[35∈3]"}}:::plan
    Connection25 --> PageInfo35
    First37{{"First[37∈3]"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈3]"]]:::plan
    PgSelectRows38 --> First37
    Lambda91 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈3]<br />ᐸmessagesᐳ"}}:::plan
    First37 --> PgSelectSingle39
    PgClassExpression40{{"PgClassExpression[40∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression40
    Access44{{"Access[44∈3]<br />ᐸ25.hasNextPageᐳ"}}:::plan
    PageInfo35 o--o Access44
    Access45{{"Access[45∈3]<br />ᐸ25.hasPreviousPageᐳ"}}:::plan
    Access44 o--o Access45
    ConnectionItems30 --> First46
    Lambda87 --> Access47
    ConnectionItems30 --> Last49
    Access77{{"Access[77∈3]<br />ᐸ87.m.joinDetailsFor55ᐳ"}}:::plan
    Lambda87 --> Access77
    Access81{{"Access[81∈3]<br />ᐸ87.m.joinDetailsFor67ᐳ"}}:::plan
    Lambda87 --> Access81
    Edge43{{"Edge[43∈6]"}}:::plan
    __Item41[/"__Item[41∈6]<br />ᐸ30ᐳ"\]:::itemplan
    PgCursor53{{"PgCursor[53∈6]"}}:::plan
    __Item41 & PgCursor53 --> Edge43
    __Item41 & Access47 --> PgCursor53
    ConnectionItems30 ==> __Item41
    PgSelectSingle42{{"PgSelectSingle[42∈6]<br />ᐸmessagesᐳ"}}:::plan
    __Item41 --> PgSelectSingle42
    List78{{"List[78∈7]<br />ᐸ77,42ᐳ"}}:::plan
    Access77 & PgSelectSingle42 --> List78
    PgClassExpression51{{"PgClassExpression[51∈7]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle42 --> PgClassExpression51
    First59{{"First[59∈7]"}}:::plan
    PgSelectRows60[["PgSelectRows[60∈7]"]]:::plan
    PgSelectRows60 --> First59
    Lambda79{{"Lambda[79∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda79 --> PgSelectRows60
    PgSelectSingle61{{"PgSelectSingle[61∈7]<br />ᐸusersᐳ"}}:::plan
    First59 --> PgSelectSingle61
    List78 --> Lambda79
    PgClassExpression63{{"PgClassExpression[63∈9]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle61 --> PgClassExpression63
    PgClassExpression65{{"PgClassExpression[65∈9]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression63 o--o PgClassExpression65
    List82{{"List[82∈10]<br />ᐸ81,42ᐳ"}}:::plan
    Access81 & PgSelectSingle42 --> List82
    PgClassExpression64{{"PgClassExpression[64∈10]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgClassExpression51 o--o PgClassExpression64
    First71{{"First[71∈10]"}}:::plan
    PgSelectRows72[["PgSelectRows[72∈10]"]]:::plan
    PgSelectRows72 --> First71
    Lambda83{{"Lambda[83∈10]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda83 --> PgSelectRows72
    PgSelectSingle73{{"PgSelectSingle[73∈10]<br />ᐸusersᐳ"}}:::plan
    First71 --> PgSelectSingle73
    List82 --> Lambda83
    PgClassExpression74{{"PgClassExpression[74∈11]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle73 --> PgClassExpression74
    PgClassExpression75{{"PgClassExpression[75∈11]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression74 o--o PgClassExpression75

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,Lambda29,PgSelectInlineApply76,PgSelectInlineApply80,PgSelectInlineApply84,Access85,PgSelectInlineApply88,Access89 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,Connection25,List86,Lambda87,List90,Lambda91 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems30,PageInfo35,First37,PgSelectRows38,PgSelectSingle39,PgClassExpression40,Access44,Access45,First46,Access47,PgCursor48,Last49,PgCursor50,Access77,Access81 bucket3
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item41,PgSelectSingle42,Edge43,PgCursor53 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression51,First59,PgSelectRows60,PgSelectSingle61,List78,Lambda79 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression63,PgClassExpression65 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression64,First71,PgSelectRows72,PgSelectSingle73,List82,Lambda83 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression74,PgClassExpression75 bucket11

